﻿CREATE TABLE [fb].[ContractAccount] (
    [AccountId]      INT NOT NULL,
    [CounterpartyId] INT NOT NULL,
    [ProductId]      INT NULL,
    CONSTRAINT [PK_fb.ContractAccount] PRIMARY KEY CLUSTERED ([AccountId] ASC),
    CONSTRAINT [FK_fb.ContractAccount_fb.Account_AccountId] FOREIGN KEY ([AccountId]) REFERENCES [fb].[Account] ([AccountId]),
    CONSTRAINT [FK_fb.ContractAccount_fb.Counterparty_CounterpartyId] FOREIGN KEY ([CounterpartyId]) REFERENCES [fb].[Counterparty] ([CounterpartyId]),
    CONSTRAINT [FK_fb.ContractAccount_fb.Product_ProductId] FOREIGN KEY ([ProductId]) REFERENCES [fb].[Product] ([ProductId])
);


GO
CREATE NONCLUSTERED INDEX [IX_AccountId]
    ON [fb].[ContractAccount]([AccountId] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_CounterpartyId]
    ON [fb].[ContractAccount]([CounterpartyId] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_ProductId]
    ON [fb].[ContractAccount]([ProductId] ASC);

